Add VIF-routing capability to xend. The default is still to bridge.
405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend
40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains
40ee75a9xFz6S05sDKu-JCLqyVTkDA tools/examples/network
+41e661e1giIEKbJ25qfiP-ke8u8hFA tools/examples/network-route
40ee75a967sxgcRY4Q7zXoVUaJ4flA tools/examples/vif-bridge
+41e661e1ooiRKlOfwumG6wwzc0PdhQ tools/examples/vif-route
40ee75a93cqxHp6MiYXxxwR5j2_8QQ tools/examples/xend-config.sxp
41090ec8Pj_bkgCBpg2W7WfmNkumEA tools/examples/xmexample1
40cf2937oKlROYOJTN8GWwWM5AmjBg tools/examples/xmexample2
# Xen script dir and scripts to go there.
XEN_SCRIPT_DIR = /etc/xen/scripts
-XEN_SCRIPTS = network
-XEN_SCRIPTS += vif-bridge
+XEN_SCRIPTS = network vif-bridge
+XEN_SCRIPTS += network-route vif-route
XEN_SCRIPTS += block-file
XEN_SCRIPTS += block-enbd
--- /dev/null
+#!/bin/sh
+#============================================================================
+# Default Xen network start/stop script.
+# Xend calls a network script when it starts.
+# The script name to use is defined in /etc/xen/xend-config.sxp
+# in the network-script field.
+#
+# Usage:
+#
+# network-route (start|stop|status) {VAR=VAL}*
+#
+# Vars:
+#
+# netdev The gateway interface (default eth0).
+# antispoof Whether to use iptables to prevent spoofing (default yes).
+#
+#============================================================================
+
+echo 1 >/proc/sys/net/ipv4/ip_forward
--- /dev/null
+#!/bin/sh
+#============================================================================
+# /etc/xen/vif-route
+#
+# Script for configuring a vif in routed mode.
+# Xend calls a vif script when bringing a vif up or down.
+# This script is the default - but it can be configured for each vif.
+#
+# Example invocation:
+#
+# vif-route up domain=VM1 vif=vif1.0 ip="128.232.38.45/28 10.10.10.55/24"
+#
+# Usage:
+# vif-route (up|down) {VAR=VAL}*
+#
+# Vars:
+#
+# domain name of the domain the interface is on (required).
+# vif vif interface name (required).
+# mac vif MAC address (required).
+# ip list of IP networks for the vif, space-separated (optional).
+#============================================================================
+
+# Exit if anything goes wrong
+set -e
+
+echo "vif-route $*"
+
+# Operation name.
+OP=$1
+shift
+
+# Pull variables in args into environment
+for arg ; do export "${arg}" ; done
+
+# Required parameters. Fail if not set.
+domain=${domain:?}
+vif=${vif:?}
+mac=${mac:?}
+
+# Optional parameters. Set defaults.
+ip=${ip:-''} # default to null (do nothing)
+
+main_ip=`ifconfig eth0 | grep "inet addr:" | sed -e 's/.*inet addr:\(\w\w*\.\w\w*\.\w\w*\.\w\w*\).*/\1/'`
+
+# Are we going up or down?
+case $OP in
+ up)
+ ifconfig ${vif} 169.254.1.0 netmask 255.255.255.255 up
+ echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp
+ iptcmd='-A'
+ ipcmd='a'
+ ;;
+ down)
+ ifconfig ${vif} down
+ iptcmd='-D'
+ ipcmd='d'
+ ;;
+ *)
+ echo 'Invalid command: ' $OP
+ echo 'Valid commands are: up, down'
+ exit 1
+ ;;
+esac
+
+if [ ${ip} ] ; then
+
+ # If we've been given a list of IP networks, allow pkts with these src addrs.
+ for addr in ${ip} ; do
+ ip r ${ipcmd} ${addr} dev ${vif} src ${main_ip}
+# iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -s ${addr} -j ACCEPT
+ done
+
+ # Always allow us to talk to a DHCP server anyhow.
+# iptables ${iptcmd} FORWARD -m physdev --physdev-in ${vif} -p udp --sport 68 --dport 67 -j ACCEPT
+fi
# Specifying the empty string '' allows all connections.
(xend-address '')
+## Use the following if VIF traffic is routed.
# The script used to start/stop networking for xend.
-(network-script network)
+#(network-script network-route)
+# The default script used to control virtual interfaces.
+#(vif-script vif-route)
+## Use the following if VIF traffic is bridged.
+# The script used to start/stop networking for xend.
+(network-script network)
# The default bridge that virtual interfaces should be connected to.
(vif-bridge xen-br0)
-
# The default script used to control virtual interfaces.
(vif-script vif-bridge)
if idx < len(vifs):
d = vifs[idx]
mac = d.get('mac')
+ if not mac:
+ mac = randomMAC()
bridge = d.get('bridge')
script = d.get('script')
backend = d.get('backend')
+ ip = d.get('ip')
else:
mac = randomMAC()
bridge = None
script = None
backend = None
+ ip = None
config_vif = ['vif']
config_vif.append(['mac', mac])
if bridge:
config_vif.append(['script', script])
if backend:
config_vif.append(['backend', backend])
+ if ip:
+ config_vif.append(['ip', ip])
config_devs.append(['device', config_vif])
def configure_vfr(config, vals):
(k, v) = b.strip().split('=', 1)
k = k.strip()
v = v.strip()
- if k not in ['mac', 'bridge', 'script', 'backend']:
+ if k not in ['mac', 'bridge', 'script', 'backend', 'ip']:
opts.err('Invalid vif specifier: ' + vif)
d[k] = v
vifs.append(d)